home *** CD-ROM | disk | FTP | other *** search
-
- ;
- ;Function cURDLE(CurDir: Char; VAR CurRow, CurCol: Byte): Boolean;
- ;
- ;Public domain software by: John M. Majkrzak
- ; 1880 Todd Dr
- ; Arden Hills, MN 55112
- ; CIS# 76617,264
- ;
- ;This procedure will return the coordinates for the next cursor move.
- ;For use with Turbo Pascal.
- ;Example call from TP: If cURDL(CurDir, CurRow, CurCol) then begin...
- ;Boolean function returns true if CurDir value was one listed below.
- ;CurRow and CurCol values are where the cursor should go next.
- ;There is no checking against register overflow because I don't need
- ;to be concerned with a monster sized display.
- ;This and all the related files are my first output as an assembler
- ;programmer and made public domain as a celebration.
-
- include pasmac.asm
-
- lArr equ 75
- rArr equ 77
- uArr equ 72
- dArr equ 80
-
- data segment word public
- assume ds:data
- extrn cwMin: Word ;Commonly assigned to TPs WindMin and
- extrn cwMax: Word ;WindMax variables by absolute ref.
- extrn cwPage: Byte ;You must specify a page (usually 0).
- data ends
-
- code segment byte public
- assume cs:code
-
- OnStack struc
- OldBP DW ?
- RetAddr DD ? ;far RetAddr DD, near is DW
- AddrCurCol DD ? ;CurCol byte. Turbo Pushes a pointer.
- AddrCurRow DD ? ;CurRow byte
- Direction DW ? ;Which way to go. Passed as char;
- OnStack ends
-
- cURDL proc far
- public cURDL
- m_Entry
- m_WhereRC <[cwPage]> ;DH = CurRow, DL = CurCol
- mov bx,[cwMin] ;BH = MinRow, BL = MinCol
- mov cx,[cwMax] ;CH = MaxRow, CL = MaxCol
- mov ax,[bp.direction] ;AL tells direction
- mov ah, -1 ;AH holds temp TF function result
- cmp al, lArr ;Want to move left?
- jne MaybeRDU
- cmp dl,bl ;we need to set col to max if it is
- jle SetMaxCol ;too small already.
- dec dl ;otherwise just decrement the curcol
- jmp short DoneReturn
- SetMaxCol:
- mov dl,cl
- CmpRow_Dec: ;test to see if we can decrement the
- cmp dh, bh ;row any further. If we can then just
- ja DecCurRow ;dec the row
- mov dh, ch ;otherwise set CurRow to max
- inc dh ;and increment it because
- DecCurRow:
- Dec dh ;decrement CurRow
- jmp Short DoneReturn
-
- MaybeRDU:
- cmp al,rArr ;Want to move right?
- jne MaybeDU
- inc dl ;If so then inc CurCol then test to see
- cmp dl,cl ;if it is too big
- jle DoneReturn
- mov dl,bl ;if so then set CurCol to MinCol
- IncCurRow:
- inc dh ;and increment the row
- cmp dh,ch ;then test to see if it is too big
- jle DoneReturn
- mov dh,bh ;if so then set CurRow to MinRow
- jmp short DoneReturn
-
- MaybeDU:
- cmp al,dArr ;want to move down?
- jne MaybeU
- jmp IncCurRow ;if so then increment the row.
-
- MaybeU:
- cmp al,uArr ;want to move up screen?
- jne NoMatch ;Input was not a cursor key.
- jmp CmpRow_Dec ;if so then decrement the row.
-
- NoMatch:
- inc ah ;Make temp result false.
- DoneReturn:
- mov al,ah ;Place TF result in AL for return
- inc dh ;Increment the results for use with
- inc dl ;GoToXY()
- sub dh, bh ;Subtract the WindMin offset so GoToXY()
- sub dl, bl ;will place the cursor inside window.
- m_RetData <AddrCurRow>, <dh>
- m_RetData <AddrCurCol>, <dl>
- m_Exit
-
- cURDL endp
- code ends
- end
-